package com.adong.springboot.mapper;

import com.adong.springboot.bean.Department;
import org.apache.ibatis.annotations.*;

/**
 * 指定操作数据库的mapper
 */
@Mapper //如果xxxMapper文件太多,可以在配置类上面添加包扫描 @MapperScan(value = "com.adong.springboot.mapper")
public interface DepartmentMapper {

    @Select("select * from department where id = #{id}")
    public Department getDeptById(Integer id);

    @Delete("delete from department where id = #{id}")
    public int deleteDeptById(Integer id);

    //使用注解可以使用生成的主键,以及主键的列
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into department(department_name) values(#{departmentName})")
    public int insertDept(Department department);


    @Update("update department set departmentName=#{departmentName} where id=#{id}")
    public int updateDept(Department department);
}
